Improve tooltip display in asynchronous callbacks - #17872
Closed
TCOTC wants to merge 1 commit into
Closed
Conversation
Check if the mouse pointer is still over the corresponding element before displaying the Tooltip in an asynchronous callback.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #14823 by preventing tooltips from being shown after asynchronous callbacks if the mouse pointer is no longer over the original target element, reducing “stuck tooltip” occurrences in fast hover-to-leave scenarios.
Changes:
- Added
showTooltipIfPointerOver()(and helperisPointerOverElement()) to guard tooltip display in async callbacks. - Updated tab header tooltip and block popover async tooltip flows to use the guarded tooltip display.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| app/src/layout/Tab.ts | Uses guarded tooltip display for async tab path tooltip. |
| app/src/dialog/tooltip.ts | Introduces pointer-over check helper and guarded tooltip function for async scenarios. |
| app/src/block/popover.ts | Uses guarded tooltip display for async asset/notebook info tooltips to avoid late popups. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+3
to
+10
| export const isPointerOverElement = (target: Element) => { | ||
| const coords = window.siyuan.coordinates; | ||
| if (!coords) { | ||
| return false; | ||
| } | ||
| const underMouse = document.elementFromPoint(coords.clientX, coords.clientY) as HTMLElement; | ||
| return !!underMouse && (target === underMouse || target.contains(underMouse)); | ||
| }; |
Member
|
使用 AbortController 方案从根本上解决。这个方案我就关闭了。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description / 描述
fix #14823
在异步回调中显示 Tooltip 前,先检查鼠标指针是否仍在对应元素上。
Type of change / 变更类型
缺陷修复
代码重构
新功能
修改文案或增加新语言
Checklist / 检查清单
我对自己的代码进行了自我审查
我拥有所提交代码的完整权利,并同意其以本项目的 AGPL-3.0 许可证授权
devbranch and has no merge conflictsPR 提交到
dev分支,并且没有合并冲突